apiready = function() {

	var userInf;
	$api.getUserInf(function(user) {
		userInf = user;
	});


	//提交建议
	$("#sub_btn").on('click', function() {

		var title = $("#title").val();
		var category = $('input[name="category"]:checked').val() || '建议';
		var content = $("#content").val();
		var account = userInf.account;
		//alert(title + category +  content)

		if (!account || !title || !category || !content) {
			$api.toastMsg('不为空');
		}



		$api.do_post('/api/property/advise/add', {
				body: JSON.stringify({
					title: title,
					category: category,
					content: content,
					account: account
				})
			},
			function(result) {

				//	$("#sub_btn").button("reset");
				if (result.code == 0) {
					$("#errmsg").text(result.msg);

					api.confirm({
					    msg: result.msg,
					    buttons: ['确定', '取消']
					}, function(ret, err){
					    if( ret ){
					   
					         api.closeWin();
					    }else{
					         alert(result.msg );
					    }
					});
					// $('#my-alert').modal({
					// 	relatedTarget: this,
					// });
					//$api.mOpenWin("index", 'index.html');
					

				} else {
					$("#errmsg").text("提交异常");
					$('#my-alert').modal({
						relatedTarget: this,
					});

				}
			});

	});
}